#ifndef POSITION_H_
#define POSITION_H_
#include <cstdlib>
#define NX 79
#define NY 20 //Taille de la carte
enum direction {HAUT=0,DROITE=1,BAS=2,GAUCHE=3};
struct position{
        //Implémentation des coordonnées
            int x;
            int y;
            position():x(0),y(0){}
            position(int x_,int y_):x(x_),y(y_)
            {

                if(x_>=NX)
                    x=NX-1;
                else if(x_<0)
                    x=0;
                else
                    x=x_;
                if(y_>=NY)
                    y=NY-1;
                else if(y_<0)
                    y=0;
                else
                    y=y_;
            }
            bool surLaMap()
            {
                if(x>=NX || x<0 || y>=NY || y<0)
                    return false;
                else
                    return true;

            }
            void changePos(int dir){
                switch(dir){
                    case HAUT:
                        y--;
                    break;
                    case  DROITE:
                        x++;
                    break;
                    case BAS:
                        y++;
                    break;
                    case GAUCHE:
                        x--;
                    break;
                    default:
                    break;
                }
            }



        bool operator==(const position& a) const
        {
            return (x == a.x && y == a.y);
        }
        bool operator!=(const position& a) const
        {
            return !(x == a.x && y == a.y);
        }
        bool operator<(const position& right) const
        {
            if(right.x != x)
                return x<right.x;
            else
                return y<right.y;
        }
};
direction convertIntToDirection(int a);
int randab(int a,int b);




#endif
